package ge.lowlevel.js.box2d;
import ge.lowlevel.box2d.WorldGe;

import com.google.gwt.core.client.JavaScriptObject;


public class WorldJs extends WorldGe<JavaScriptObject>
{
	private JavaScriptObject world;
	 
	public WorldJs(double xGravity, double yGravity, double minVertex,double maxVertex,boolean doSleep,double scale)
	{	 
		//Super call does nothing
		super(xGravity, yGravity, minVertex, maxVertex, doSleep,scale);
		init(xGravity, yGravity, minVertex, maxVertex,doSleep);
		
	}
	
	private native void init(double xGravity, double yGravity, double minVertex,double maxVertex,boolean doSleep)
	/*-{
	
	 	var worldAABB = new $wnd.b2AABB();
		worldAABB.minVertex.Set(minVertex, minVertex);
		worldAABB.maxVertex.Set(maxVertex, maxVertex);
		var gravity = new $wnd.b2Vec2(xGravity, yGravity);
		var dS = doSleep;
		var world = new $wnd.b2World(worldAABB, gravity, dS);
		this.@ge.lowlevel.js.box2d.WorldJs::world = world;
		//$wnd.alert(this.@ge.lowlevel.js.box2d.WorldJs::world);
	}-*/;
	
	
	 
	@Override
	public JavaScriptObject getWorld()
	{
		return world;
	}
	@Override
	public native void step(double timeStep, double iteration)
	/*-{
		
		var w = this.@ge.lowlevel.js.box2d.WorldJs::world;
		w.Step(timeStep,iteration);
		//$wnd.alert(w.m_bodyCount);
	}-*/;
	@Override
	public native final int bodyCount()
	/*-{
		return this.@ge.lowlevel.js.box2d.WorldJs::world.m_bodyCount;
		
	}-*/;
	
	
}
